package com.company;

import  com.company.Car.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.System.*;


public class Main {

    //*
        public static void main(String args[]){
        Car car = new Car();
        System.out.println("轮胎的颜色是:"+car.getTyreInfo().getColor()+"\t轮胎的材质是:"+car.getTyreInfo().getMaterial());
        //无参构造
        System.out.println("车的颜色是:"+car.getColor()+"\t车的品牌是:"+car.getBrand());
        //有参构造
        Car car2 = new Car("绿色","凯德拉克");
        System.out.println("车的颜色是:"+car2.getColor()+"\t车的品牌是:"+car2.getBrand());

        //工厂模式实例
         Main car3 = new Main();
         car3.testFactory();

        System.out.println("Get Start!!");
        Scanner sc = new Scanner(System.in);
        String tmp = sc.next();
        if ( tmp.toLowerCase().equals("start"))
        car.checkGassEnough();
        out.println(Math.sqrt(200));
    }
    private void testFactory(){
            Car c = CarGardener.factor();
    }
    // */
    /*
     //4.求阶乘的前n项和
    public static void main(String args[]){
        System.out.println("请输入项数：");
        Scanner sc = new Scanner(System.in);
        int totnum = 0,n = Integer.parseInt(sc.next());
        for (int i=1;i<=n;i++){
          totnum += fac(i);
        }
        System.out.println(n+"!的前n项和为"+totnum);
    }
    public static int fac(int n){
        if(n>1)
            return n*fac(n-1);
        else
            return 1;
    }
     */

    /*
        //1.求输入数的和
    public static void main(String[] args) {

        int totNum = 0;
        System.out.println("请输入一个整数：");
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext())
        {
            String tmp = sc.next();
            if (tmp.equals("/0"))
                break;
            totNum += Integer.parseInt(tmp);
            System.out.println("请输入一个整数，如需结束请输入'/0'：");
        }
        System.out.println("输入数字的和为："+totNum);
    }
     */
    /*
        public static void main(String[] args) {
        //2.数组复制排序和部分排序以及实习冒泡排序
        int a[] = {1,43,23,12,32,34,33,21,14,35,65};
        int b[] = new int[a.length];
        int c[] = new int[a.length];
        System.arraycopy(a,0,b,0,a.length);
        System.out.print("排序前a[]：");
        for(int i:a)
            System.out.print(i + " ");
        Arrays.sort(a);
        Arrays.sort(b,0,5);
        c = mySort(a);
        System.out.print("\n完全排序后a[]:");
        for (int i:a)
            System.out.print(i + " ");
        System.out.print("\nmySort().a[]:");
        for (int i:c)
            System.out.print(i+" ");
        System.out.print("\n前五个部分排序的结果是a[]:");
        for (int i:b)
            System.out.print(i + " ");

        //数组比较
        boolean arrayEqual = false;
        if (Arrays.equals(a,c))
            arrayEqual = true;
        System.out.println("\nArrays.sort方法和mySort方法效果是"+(arrayEqual?"一样的":"不一样"));

        public  static int[] mySort(int a[])
    {
        int tmp;
        for (int i:a)
        {
           for (int j=i+1;j<a.length;j++)
            {
                if (a[i]>a[j])
                {
                    tmp =  a[j];
                    a[j] = a[i];
                    a[i]= tmp;
                }
            }
        }
        return  a;
    }
    }
     */
    /*
     //3.字符串分割--查找绝对路径下的文件名
    public static void main(String args[]){

        String str = new String("E:\\快捷方式文件夹\\ShadowsocksR-4.7.0 (1)\\pac.txt");
        String dstStr = str.substring(str.lastIndexOf("\\")+1);
        System.out.println("文件名为："+dstStr);
    }
     */



}
